console.log(100)
setTimeout(() => {
  console.log(200)
}, 0)
Promise.resolve().then(() => {
  console.log(300)
})
console.log(400)
// 答案： 100--400--300--200

// setTimeout 属于宏任务，Promise属于微任务
// 宏任务-->微任务-->页面渲染-->宏任务

async function async1(){
  console.log('async start');
  await async2()
  console.log('async end');
}

async function async2(){
  console.log('async2');
}

console.log('script start');

setTimeout(() => {
  console.log('setTimeout');
}, 0);

async1()

new Promise(function (resolve){
  console.log('promise1');
  resolve()
}).then(function(){
  console.log('promise2');
}).then(function(){
  console.log('promise3');
})

console.log('script end');

// 答案: script start---async start---async2---async end---script end---promise1---promise2---setTimeout
